#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2019, Intel Corporation

#
# src/test/ctl_cow/TEST3 -- unit test which checks if opening pool located
# on Device DAX when copy_on_write.at_open=1 fails
#

. ../unittest/unittest.sh

require_test_type medium
require_dax_devices 1
dax_device_zero

setup

POOL="$DIR/testfile"
POOLSET_DAX="$DIR/dax.set"

create_poolset $POOLSET_DAX AUTO:${DEVICE_DAX_PATH[0]} O SINGLEHDR

expect_normal_exit $PMEMPOOL$EXESUFFIX create obj $POOLSET_DAX

expect_normal_exit $PMEMPOOL$EXESUFFIX create -s 32MB obj $POOL

PMEMOBJ_CONF="copy_on_write.at_open=1;"

# check if opening non-dax pool does not fail
expect_normal_exit ./ctl_cow$EXESUFFIX $POOL dax

# check if opening dax pool fails
expect_abnormal_exit ./ctl_cow$EXESUFFIX $POOLSET_DAX dax

check

pass
